<?
	
	if(isset($_POST['btnsubmit']))
	{
		require("required/dbconnect.php");
		require("required/email.php");

		$verycode=$_POST['verification_code'];
		
		
		if($verycode!=$_SESSION['vericode'])
		{
			header("Location:os_contactus2.php?c=3&verycode=$verycode");
			die();
		}
		
		
		$company_name=mysql_escape_string($_POST['company_name']);
		$contact_person=mysql_escape_string($_POST['contact_person']);
		$designation = $_POST['designation'] ;
		$tel=$_POST['tel'];
		$fax=$_POST['fax'];
		$email=$_POST['email'];
		$address=$_POST['address'];
		$message=$_POST['message'];
		$ip=$_SERVER [ 'REMOTE_ADDR' ];
		
		$get_info=mysql_query("select * from os_contactinfo where id=1");
		$i=mysql_fetch_array($get_info,MYSQL_ASSOC);
		
		$websitename_eng=$i['website_name'];
		$logo_url=$i['logo_url'];
		$os_url=$i['website'];
		$admin_email=$i["email_hidden"];
		
		$to="$admin_email"; //receiver email here
			
		//------------------------ get data -----------------------------------
		
		$subject=$websitename_eng." Enquiry";		
		
		
		//-----------------------------------Body begin----------------------------
		$body="
		<html>
		<head>
		<style type='text/css'>
		<!--
			html,body,td,th {
		font-family: tahoma;
		font-size: 11px;
		margin-top:0px;
		margin-bottom:0px;
		
		
		}
		-->
		</style>
		</head>
		<body>
		<table>
			<tr>
				<td colspan=3><strong>$websitename_eng Enquiry System</strong></td>
			</tr>
			
			<tr>
				<td>Contact person</td><td>:</td><td>$contact_person</td>
			</tr>
			<tr>
				<td>Designation</td><td>:</td><td>$designation</td>
			</tr>
			<tr>
				<td>Company Name</td><td>:</td><td>$company_name</td>
			</tr>
			<tr>
				<td>Tel</td><td>:</td><td>$tel</td>
			</tr>
			<tr>
				<td>Fax</td><td>:</td><td>$fax</td>
			</tr>
			<tr>
				<td>Email</td><td>:</td><td>$email</td>
			</tr>
			<tr  valign=top>
				<td>Address</td><td>:</td><td>".str_replace("\n","<br>",$address)."</td>
			</tr>
			<tr>
				<td>IP</td><td>:</td><td>$ip</td>
			</tr>
			<tr>
				<td>Submit Datetime</td><td>:</td><td>".date('Y-m-d H:i:s')."</td>
			</tr>
			<tr valign=top>
				<td>Message</td><td>:</td><td>".str_replace("\n","<br>",$message)."</td>
			</tr>
			
			
		</table>
		</body>
		</html>	"; 
	//-------------------------------- end of body ---------------------------------
	
		
		
		
		$insert=mysql_query("insert into os_contactus(company_name,contact_person,designation,tel,fax,email,address,message,create_datetime,ip_address)
							 values('$company_name','$contact_person','$designation','$tel','$fax','$email','$address','$message',now(),'$ip')");
		
		email_send($body,$to,"",$subject,"",$i['email']);
		header("Location:os_contactus2.php?c=1&verycode=$verycode");
		
	}
	else
	{
		
	 $pid=10;	
	 $title="Contact Us ";
	 
	 require("required/dbconnect.php");
	 
	 
	require("required/share_function.php");
	$_SESSION['pid']="contact_us";
	 require("required/header.php");
	
	 
	 $get_info=mysql_query("select * from os_contactinfo where id=1");
	 $a=mysql_fetch_array($get_info,MYSQL_ASSOC);
	  ?>

<script type="text/javascript">
 
	function check(frm){
		if(document.frm.contact_person.value=="")
		{
			alert("Please enter contact person");
			document.frm.contact_person.focus();
			return false;
		}
		if(document.frm.tel.value=="")
		{
			alert("Please enter contact number");
			document.frm.tel.focus();
			return false;
		}
		if(document.frm.email.value=="")
		{
			alert("Please enter email");
			document.frm.email.focus();
			return false;
		}
		if(document.frm.email.value!="")
		{
		 	var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
		   	var address = document.frm.email.value;
		   	if(reg.test(address) == false) {
				alert("Invalid email");
				document.frm.email.focus();
				return false;
			 }
		}
		if(document.frm.verification_code.value=="")
		{
			alert("Please enter verification_code");
			document.frm.verification_code.focus();
			return false;
		}
		
	
	}
</script>	 

<table width="100%" align="center" cellpadding="6" cellspacing="0">
    <tr>
        <td class='page_title_bar'>
        Contact us
                
        </td>					
    </tr>	
    <tr>
    	<td>
        <table width="90%" align="center">
		<tr>
			<td>
				<table width="100%">
					<td>
						For any enquiries, kindly contact us at:
						<br /><br />
                        <?= $a['company_name'] ?><br />
                        <?= $a['address1'] ?><br />
                        <?= $a['address2'] ?><br />
                        <?= $a['address3'] ?><br />
                        <br /><br />
                        Tel: <?= $a['contact_number'] ?><br />
                        Fax: <?= $a['fax'] ?><br />
                        Email: <?= $a['email'] ?><br />



					</td>
				</table>
			</td>
		</tr>
		
		<tr>
			<td><script src='required/valiform.js'></script>
			<br><br>
			<strong>You can send your enquiry by submitting the form below.	</strong>	
			<FORM ACTION="<?= $_SERVER['PHP_SELF'] ?>" METHOD="POST" name="frm" onSubmit="return check(this);">
				<table width="100%" cellpadding="5">
					<TR> 
						<TD VALIGN="MIDDLE" class="insidetext">Name of Company</TD>
						<TD WIDTH="7" VALIGN="MIDDLE" class="insidetext">:</TD>
						<TD VALIGN="MIDDLE" class="insidetext"> <INPUT TYPE="TEXT" NAME="company_name" SIZE="25" MAXLENGTH="100" class="text">
						</TD>
						
					  </TR>
					
					  
					  <TR> 
						<TD VALIGN="MIDDLE" class="insidetext">Person to Contact</TD>
						<TD WIDTH="7" VALIGN="MIDDLE" class="insidetext">:</TD>
						<TD VALIGN="MIDDLE" class="insidetext"> <INPUT TYPE="TEXT" NAME="contact_person" SIZE="25" MAXLENGTH="100" class="text"></TD>
					  </TR>
					   <TR> 
						<TD VALIGN="MIDDLE" class="insidetext">Designation</TD>
						<TD WIDTH="7" VALIGN="MIDDLE" class="insidetext">:</TD>
						<TD VALIGN="MIDDLE" class="insidetext"> <INPUT TYPE="TEXT" NAME="designation" SIZE="25" MAXLENGTH="100" class="text"></TD>
					  </TR>
					  <TR> 
						<TD VALIGN="middle" class="insidetext">Telephone number</TD>
						<TD WIDTH="7" VALIGN="middle" class="insidetext">:</TD>
						<TD VALIGN="MIDDLE" class="insidetext"> <INPUT TYPE="TEXT" NAME="tel" SIZE="25" class="text">
						 </TD>
					  </TR>
					   <TR> 
						<TD VALIGN="middle" class="insidetext">Fax</TD>
						<TD WIDTH="7" VALIGN="middle" class="insidetext">:</TD>
						<TD VALIGN="MIDDLE" class="insidetext"> <INPUT TYPE="TEXT" NAME="fax" SIZE="25" class="text">
						 </TD>
					  </TR>
					  <TR> 
						<TD VALIGN="MIDDLE" class="insidetext">E-mail</TD>
						<TD WIDTH="7" VALIGN="MIDDLE" class="insidetext">:</TD>
						<TD VALIGN="MIDDLE" class="insidetext"> <INPUT TYPE="TEXT" NAME="email" SIZE="25" MAXLENGTH="60" class="text">
						</TD>
					  </TR>
					   <TR> 
						<TD VALIGN="TOP" class="insidetext">Address</TD>
						<TD WIDTH="7" VALIGN="TOP" class="insidetext">:</TD>
						<TD VALIGN="TOP" class="insidetext"> <TEXTAREA NAME="address" COLS="35" ROWS="4" class="text"></TEXTAREA> 
						</TD>
					  </TR>
					  <TR> 
						<TD VALIGN="TOP" class="insidetext">Comment/Query</TD>
						<TD WIDTH="7" VALIGN="TOP" class="insidetext">:</TD>
						<TD VALIGN="TOP" class="insidetext"> <TEXTAREA NAME="message" COLS="35" ROWS="4" class="text"></TEXTAREA> 
						</TD>
					  </TR>
					  <tr>
						<td>Verification code<font color="#FF0000">*</font></td><td>:</td><td>
						<input type="text" class="text" size="4" maxlength="4" name="verification_code">
						<iframe name="I1" src="verycode.php" width="60" height="20" frameborder=0 scrolling=no  marginheight="0"></iframe>   </td>
					  </tr>
					  <TR> 
						<TD>&nbsp;</TD>
						<TD WIDTH="7">&nbsp;</TD>
						<TD><INPUT NAME="btnsubmit" TYPE="submit" class="button" VALUE="Submit"> 
						  <B> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</B> </TD>
					  </TR>

					
				</table>
				</form>
                </table></td></tr>
			</td>
		</tr>		
	</table>

<? }require("required/footer.php") ?>